package com.shanzmoo.base.util;


import cn.hutool.core.util.StrUtil;

import java.util.Scanner;

/**
 * 控制台读取工具类
 * @author: Gzhao 2020/12/9
 */
public class ScannerUtils {

    private ScannerUtils(){}

    /**
     * <p>
     * 读取控制台内容
     * </p>
     */
    public static String scanner(String tip) {
        Scanner scanner = new Scanner(System.in);

        StringBuilder content = new StringBuilder();
        content.append("请输入" + tip + "：");

        System.out.println(content.toString());
        if (scanner.hasNext()) {
            String ipt = scanner.next();
            if (StrUtil.isNotBlank(ipt)) {
                return ipt;
            }
        }
        return null;
    }
}
